<?php

// use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
use Illuminate\Support\Facades\Route;
use Illuminate\Contracts\Routing\Registrar as RouteRegisterContract;

Route::domain('api.'.env('APP_DOMAIN'))->namespace('Api')->group(function (RouteRegisterContract $route) {
    $route->middleware('api')->group(function (RouteRegisterContract $route) {
        $route->group(['prefix' => '/upload'], function (RouteRegisterContract $route) {
            $route->post('/img', 'ToolController@uploadImg');
        });

        $route->group(['prefix' => '/user'], function (RouteRegisterContract $route) {
            //测试方法
            $route->get('/get', 'UserController@get');
            //用户登录接口
            $route->post('/login', 'UserController@login');
            //用户注册接口
            $route->any('/register', 'UserController@register');
        });

        $route->group(['prefix' => '/tool'], function (RouteRegisterContract $route) {
            //发送邮件验证码
            $route->get('/emailCaptcha', 'ToolController@emailCaptcha')->name('emailCaptcha');

            $route->get('/captcha', 'ToolController@captcha');

            $route->get('/clearCache', 'ToolController@clearCache');
        });

        $route->group(['prefix' => '/admin'], function (RouteRegisterContract $route) {
            $route->post('/doLogin', 'AdminController@doLogin')->name('admin/doLogin');
        });

        $route->group(['prefix' => '/issue'], function (RouteRegisterContract $route) {
            $route->post('/add', 'IssueController@add')->name('issue/add');
        });
    });

    $route->middleware('api.user.auth')->group(function (RouteRegisterContract $route) {
    });

});
